/*
 * @Author: shiguo
 * @Date: 2023-07-21 16:15:33
 * @LastEditors: shiguo
 * @LastEditTime: 2023-07-25 09:31:26
 * @FilePath: /@aks-dev/ipush/src/RNIpush.ts
 */

import { NativeModules, Platform, NativeEventEmitter, DeviceEventEmitter, EmitterSubscription } from 'react-native';

const { RNIpush } = NativeModules;


export const getInfo = () => RNIpush.info()



export const onNotificationMessageArrived:
    (listener: (event: any) => void) => EmitterSubscription
    = (listener) => {
        if (Platform.OS == 'ios') {
            return new NativeEventEmitter(RNIpush).addListener('onNotificationMessageArrived', listener);
        } else {
            /**
             *  new NativeEventEmitter(RNUpushModule) ,也可以监听
             */
            return DeviceEventEmitter.addListener("onNotificationMessageArrived", listener)
        }
    }


export const onNotificationMessageClicked:
    (listener: (event: any) => void) => EmitterSubscription
    = (listener) => {
        if (Platform.OS == 'ios') {
            return new NativeEventEmitter(RNIpush).addListener('onNotificationMessageClicked', listener);
        } else {
            /**
             *  new NativeEventEmitter(RNUpushModule) ,也可以监听
             */
            return DeviceEventEmitter.addListener("onNotificationMessageClicked", listener)
        }
    }